package eteam.aps.gateway.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;

//@Configuration
public class FeignRequestConfig implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        /*
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        if (requestAttributes != null) {
            try {
                HttpServletRequest request = requestAttributes.getRequest();
                //request.setCharacterEncoding("utf-8");
                Enumeration<String> headerNames = request.getHeaderNames();
                if (headerNames != null) {
                    while (headerNames.hasMoreElements()) {
                        String name = headerNames.nextElement();
                        String values = request.getHeader(name);
                        requestTemplate.header(name, values);
                    }
                }
                StringBuffer body = new StringBuffer();
                Enumeration<String> bodyNames = request.getParameterNames();
                if (bodyNames != null) {
                    Map map = new HashMap();
                    while (bodyNames.hasMoreElements()) {
                        String name = bodyNames.nextElement();
                        String values = request.getParameter(name);
                        requestTemplate.query(name, values);
                        map.put(name, values);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        */
    }
}